package org.example.controller;

import org.example.jd.aiservice.JdAiSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jdai")
public class AIServiceJD {

    @Autowired
    private JdAiSerivce jdAiSerivce;

    /**
     * 处理聊天请求，接收用户消息并返回AI助手的回复
     * @param message 用户发送的消息内容，默认值为"Hello"
     * @param userId 用户唯一标识符，默认值为"111"
     * @return AI助手对用户消息的回复字符串
     */
    @GetMapping("/chat")
    public String chat( @RequestParam(value = "message", defaultValue = "Hello") String message,
                        @RequestParam(value = "userId", defaultValue = "111")String userId) {
        String result = jdAiSerivce.sendMessage(userId, message);
        return result;
    }

}
